package com.fr.chart.plot;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.axis.RadarAxis;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.glyph.PlotGlyph;
import com.fr.chart.core.glyph.RadarAxisGlyph;
import com.fr.chart.core.glyph.RadarPlotGlyph;
import com.fr.chart.legend.LineMarkerIcon;
import com.fr.data.ChartData;

public class RadarPlot extends Plot
{
  private static final long serialVersionUID = 224372350182474023L;
  private RadarAxis radarAxis = new RadarAxis();
  private boolean isFilled = false;
  private boolean showLine = true;
  private boolean showMarker = true;

  protected LineMarkerIcon getLineMarkerIconByIndex(int paramInt)
  {
    return getLineMarkerIconByIndex4Line(paramInt);
  }

  public PlotGlyph createPlotGlyph(ChartData paramChartData)
  {
    RadarPlotGlyph localRadarPlotGlyph = new RadarPlotGlyph();
    install4PlotGlyph(localRadarPlotGlyph, paramChartData);
    createAxisGlyph(localRadarPlotGlyph, paramChartData);
    return localRadarPlotGlyph;
  }

  public void install4PlotGlyph(RadarPlotGlyph paramRadarPlotGlyph, ChartData paramChartData)
  {
    super.install4PlotGlyph(paramRadarPlotGlyph, paramChartData);
    paramRadarPlotGlyph.setFilled(this.isFilled);
    paramRadarPlotGlyph.setShowLine(this.showLine);
    paramRadarPlotGlyph.setShowMarker(this.showMarker);
  }

  private void createAxisGlyph(RadarPlotGlyph paramRadarPlotGlyph, ChartData paramChartData)
  {
    RadarPlotGlyph localRadarPlotGlyph = paramRadarPlotGlyph;
    RadarAxisGlyph localRadarAxisGlyph = new RadarAxisGlyph(this.radarAxis);
    localRadarAxisGlyph.setCategoryCount(paramChartData.getCategoryLabelCount());
    localRadarAxisGlyph.initMinMaxValue(getMinValueFromData(paramChartData), getMaxValueFromData(paramChartData));
    int i = 0;
    int j = paramChartData.getCategoryLabelCount();
    while (i < j)
    {
      localRadarAxisGlyph.addCategoryLabel((paramChartData.getCategoryLabel(i) == null) ? "" : paramChartData.getCategoryLabel(i));
      ++i;
    }
    localRadarPlotGlyph.setRadarAxisGlyph(localRadarAxisGlyph);
  }

  protected boolean showLegendLine()
  {
    return this.showLine;
  }

  protected boolean showLegendMarker()
  {
    return this.showMarker;
  }

  public RadarAxis getRadarAxis()
  {
    return this.radarAxis;
  }

  public void setRadarAxis(RadarAxis paramRadarAxis)
  {
    this.radarAxis = paramRadarAxis;
  }

  public boolean isFilled()
  {
    return this.isFilled;
  }

  public void setIsFilled(boolean paramBoolean)
  {
    this.isFilled = paramBoolean;
  }

  public boolean isShowLine()
  {
    return this.showLine;
  }

  public void setShowLine(boolean paramBoolean)
  {
    this.showLine = paramBoolean;
  }

  public boolean isShowMarker()
  {
    return this.showMarker;
  }

  public void setShowMarker(boolean paramBoolean)
  {
    this.showMarker = paramBoolean;
  }

  public boolean match4GUI(Plot paramPlot)
  {
    return ((super.match4GUI(paramPlot)) && (((RadarPlot)paramPlot).isFilled == this.isFilled) && (((RadarPlot)paramPlot).showLine == this.showLine) && (((RadarPlot)paramPlot).showMarker == this.showMarker));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str2;
      String str1 = paramXMLableReader.getTagName();
      if ("RadarAttr".equals(str1))
      {
        if ((str2 = paramXMLableReader.getAttr("showMarker")) != null)
          setShowMarker(Boolean.valueOf(str2).booleanValue());
        if ((str2 = paramXMLableReader.getAttr("showLine")) != null)
          setShowLine(Boolean.valueOf(str2).booleanValue());
        if ((str2 = paramXMLableReader.getAttr("isFilled")) != null)
          setIsFilled(Boolean.valueOf(str2).booleanValue());
      }
      else if ("RadarAxis".equals(str1))
      {
        if (((str2 = paramXMLableReader.getAttr("class")) != null) && (str2.endsWith(".RadarAxis")))
          this.radarAxis = ((RadarAxis)paramXMLableReader.readXMLObject(new RadarAxis()));
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Plot");
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("RadarAttr").attr("showMarker", this.showMarker).attr("showLine", this.showLine).attr("isFilled", this.isFilled).end();
    if (this.radarAxis != null)
      this.radarAxis.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof RadarPlot))
      return false;
    RadarPlot localRadarPlot = (RadarPlot)paramObject;
    if (!(super.equals(localRadarPlot)))
      return false;
    if (localRadarPlot.isFilled() != isFilled())
      return false;
    if (localRadarPlot.isShowLine() != isShowLine())
      return false;
    if (localRadarPlot.isShowMarker() != isShowMarker())
      return false;
    return (Equals.equals(localRadarPlot.radarAxis, this.radarAxis));
  }
}